﻿namespace CyberConnect.Insteon.Messaging
{
    [System.ComponentModel.ImmutableObject(true)]
    public sealed class DeviceMessageEcho : DeviceMessageDecorator, IEcho
    {
        private readonly EchoState _EchoResult;

        internal DeviceMessageEcho(DeviceMessage message, EchoState echoResult)
            : base(message)
        {
            this._EchoResult = echoResult;
        }

        #region IEcho Members

        /// <summary>
        /// Returns a value indicating if this echo is a success echo.
        /// </summary>
        public bool IsValidEcho
        {
            get
            {
                return this.IsEcho && this.EchoResult == EchoState.Ack;
            }
        }

        /// <summary>
        /// Returns a value indicating if this message is an Echo.
        /// </summary>
        public bool IsEcho
        {
            get { return this.EchoResult == EchoState.Ack || this.EchoResult == EchoState.Nak; }
        }

        /// <summary>
        /// Holds the acknowledgement byte of an echo.
        /// </summary>
        public EchoState EchoResult { get { return _EchoResult; } }

        #endregion IEcho Members
    }
}